package com.imot.controller;

import com.imot.pojo.dto.AddExperimentDataDto;
import com.imot.pojo.dto.AddReportDataDto;
import com.imot.pojo.entity.ReportFiles;
import com.imot.response.Result;
import com.imot.service.ReportDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.time.LocalDateTime;

/**
 * ClassName: ReportDataController
 * Description:
 * date: 2023/11/30 11:41
 *
 * @author imot-jiah.wang
 */
@Api(tags = "报告数据控制器")
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/reportData")
public class ReportDataController {

    private final ReportDataService reportDataService;

    @ApiOperation("新增报告数据")
    @PostMapping("/addReportData")
    public Result addReportData(@ModelAttribute AddReportDataDto addReportDataDto){
        log.info("~~~~~~~~~~~~~~~~~~{}",addReportDataDto);
        Result result = reportDataService.addReportData(addReportDataDto);
        return result;
    }

    @ApiOperation("删除报告数据")
    @DeleteMapping("/deleteReportData")
    public Result deleteReportData(Integer id){
        Result result = reportDataService.deleteReportData(id);
        return result;
    }

//    @ApiOperation("修改报告数据")
    @PutMapping("/updateReportData")
    public Result updateReportData(ReportFiles reportFiles){
        Result result = reportDataService.updateReportData(reportFiles);
        return result;
    }

    @ApiOperation("查找报告数据")
    @GetMapping("/getReportData")
    public Result getReportData(@RequestParam(required = false)Integer page,
                                                      @RequestParam(required = false)Integer limit,
                                                      @RequestParam(required = false) LocalDateTime start,
                                                      @RequestParam(required = false)LocalDateTime end,
                                                      @RequestParam(required = false)String reportType,
                                                      @RequestParam(required = false)String reportName){
        Result result = reportDataService.getReportData(page,limit,start,end,reportType,reportName);
        return result;
    }

    @ApiOperation("获取报告详情")
    @GetMapping("/getReportDataDetails")
    public Result getReportDataDetails(Integer id){
        Result result = reportDataService.getReportDataDetails(id);
        return result;
    }
}

